<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="telephone=no" name="format-detection">
<link rel="stylesheet" type="text/css" href="../static/easyui/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="../static/easyui/themes/icon.css">
<link rel="stylesheet" href="../static/css/style.css" />
<link rel="stylesheet" href="../static/css/tcommon.css" />
<script src="../static/jquery/jquery-1.12.4.js"></script>
<script src="../static/easyui/jquery.easyui.min.js"></script>
<script src="../static/easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../static/js/echarts.min.js"></script>
<title>压力记录</title>
</head>

<body style="text-align: center;">

	<div class="search-container" style="margin: 10px 0;">
		<div class="search-input">
			日期：
			<input class="easyui-datebox" id="date">
	</div>

	<div id='container' style="width: 95%; margin-left: 10px; margin-top: 5px;">
	</div>
</body>
<script th:inline="javascript">
    var equipmentid = [[${id}]];
    $(document).ready(function(){
    	var date = new Date();
    	$("#date").datebox("setValue",formatDate(date));
    });
    $('#date').datebox({
		onChange: function() {
			load()
		}
	});
    function load(){
    	var date = $("#date").datebox("getValue");
    	$.ajax({
			type : 'get',
			url : "../PressureCirlce?equipmentid=" + equipmentid+"&date="+date,
			contentType : "application/json",
			success : function(data) {
				$("#container").empty();
				$.each(data,function(i,arr){
					if(arr.length==0){
						return true;
					}
					$("#container").append("<div id='chart"+i+"' style='height: 300px;'></div>")
					var dates = [];
					var rotates = [];
					var pushs = [];
					var muds = [];
					$.each(arr,function(j,row){
						dates.push(formatTime(row.date));
						rotates.push(row.rotate.toFixed(2));
						pushs.push(row.push.toFixed(2));
						muds.push(row.mud.toFixed(2));
					})
					var dom = document.getElementById("chart"+i);
					myChart = echarts.init(dom);
					
					option = {
							tooltip: {
								trigger: 'axis',
								//					axisPointer: {
								//						animation: false
								//					},
								//      formatter:'{b}\r : \r{c}'
							},
							color: ['#BDEB7B', '#4B8BF4', '#A3D7F9'],
							grid: {
								left: 10,
								top: 40,
								bottom: 0,
								right: 10,
								containLabel: true
							},
							xAxis: {
								type: 'category',
								name: '时间',
								boundaryGap: false,
								data: dates,
								splitLine: {
									show: false
								},
								axisLine: {
									show: true,
									lineStyle: {
										color: '#333',
									}
								},
								axisLabel: { //坐标轴刻度标签的相关设置
									textStyle: {
										color: '#333',
										fontSize: 16
									}
								},
							},
							yAxis: {
								type: 'value',
								name: '（油压）Mpa',
								nameGap: 5,
								splitNumber: 3,
								splitLine: {
									show: false
								},
								axisLine: {
									show: true,
									lineStyle: {
										color: '#333',
									}
								},
								axisLabel: { //坐标轴刻度标签的相关设置
									textStyle: {
										color: '#333',
										fontSize: 16
									}
								},
							},
							series: [{
								name: '旋转',
								type: 'line',
								showSymbol: false,
								symbol: 'circle',
								hoverAnimation: false,
								data: rotates,
								itemStyle: {
									normal: {
										lineStyle: {
											color: '#BDEB7B' //改变折线颜色
										}
									}
								}
							},{
								name: '推拉',
								type: 'line',
								showSymbol: false,
								symbol: 'circle',
								hoverAnimation: false,
								data: pushs,
								itemStyle: {
									normal: {
										lineStyle: {
											color: '#4B8BF4' //改变折线颜色
										}
									}
								}		
							},{
								name: '夹具',
								type: 'line',
								showSymbol: false,
								symbol: 'circle',
								hoverAnimation: false,
								data: muds,
								itemStyle: {
									normal: {
										lineStyle: {
											color: '#A3D7F9' //改变折线颜色
										}
									}
								}
							}]
						};
						if(option && typeof option === "object") {
							myChart.setOption(option, true);
						}

				})
			},
			dataType : "json"
		});
    }
    function formatDate(time) {
		var date = new Date(time);
		var year = date.getFullYear(),month = date.getMonth() + 1, //月份是从0开始的
		day = date.getDate(),hour = date.getHours(),min = date.getMinutes(),sec = date.getSeconds();
		var newTime = year + '-' + month + '-' + day;
		return newTime;
	}
    
    function formatTime(time){
		if(time){
			return dateFormat("HH:MM:SS",new Date(time))
		}else{
			return '';
		}
	}
	function dateFormat(fmt, date) {
	    let ret;
	    let opt = {
	        "Y+": date.getFullYear().toString(),        // 年
	        "m+": (date.getMonth() + 1).toString(),     // 月
	        "d+": date.getDate().toString(),            // 日
	        "H+": date.getHours().toString(),           // 时
	        "M+": date.getMinutes().toString(),         // 分
	        "S+": date.getSeconds().toString()          // 秒
	        // 有其他格式化字符需求可以继续添加，必须转化成字符串
	    };
	    for (let k in opt) {
	        ret = new RegExp("(" + k + ")").exec(fmt);
	        if (ret) {
	            fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (padStart(opt[k],ret[1].length, "0")))
	        };
	    };
	    return fmt;
	}
	function padStart(string,length,char){
		var str = string;
		for(var i=0;i<length-string.length;i++){
			str=char+str
		}
		return str
	}
</script>
<style>
.sc-calendar {
	width: 500px;
	height: 500px;
	text-align: center;
	font-family: "Microsoft Yahei";
	color: #4A4A4A;
	box-shadow: 2px 4px 5px #bdbdbd;
	border-width: 1px 0 0 1px;
	border-color: #E6E4E0;
	border-style: solid;
	float: left;
	margin-right: 20px;
	-moz-user-select: none;
	/*鐏嫄*/
	-webkit-user-select: none;
	/*webkit娴忚鍣?*/
	-ms-user-select: none;
	/*IE10*/
	user-select: none;
	-webkit-text-size-adjust: none;
	font-size: 16px;
}

.sc-header {
	height: 35px;
	border-bottom: 0;
}

.sc-body {
	height: 93%;
	clear: both;
	box-shadow: 2px 4px 5px #bdbdbd;
}

.sc-week {
	height: 12%;
	font-weight: 400;
	font-size: 20px;
	color: #4A4A4A;
}

.sc-days {
	height: 88%;
}

.sc-item {
	height: 20%;
	float: left;
	font-weight: 600;
	color: #565555;
	width: 14.285%;
	padding-top: 10px;
	background-color: #ffffff;
	border-width: 0 0 1px 1px;
	border-color: #F1EBE4;
	border-style: solid;
	box-sizing: border-box;
}

.item-nolunar {
	padding-top: 20px;
}

.sc-item:nth-child(7n) .day, .sc-item:nth-child(7n+6) .day {
	color: rgba(224, 8, 8, 0.74);
}

.sc-vocation {
	background-color: #FFEBEC;
}

.sc-mark {
	background-color: #E5FBFA;
}

.sc-vocation:before {
	content: '浼?';
	display: block;
	position: absolute;
	font-size: 0.7em;
	width: 1.2em;
	font-weight: 100;
	color: white;
	background-color: #E00808;
	margin-top: -10px;
}

.sc-othermenth {
	color: #C1C0C0 !important;
}

.sc-othermenth .day, .sc-othermenth .lunar-day {
	color: #C1C0C0 !important;
}

.sc-active-day, .sc-selected {
	border: 1px solid orange;
}

.sc-today {
	background-color: orange;
	color: white;
	border: 1px solid blue;
}

.sc-hasreport {
	background-color: #33CCFF;
	color: white;
	border: 1px solid #33CCFF;
}

.sc-item .day {
	font-size: 1.5em;
}

.sc-today .day {
	color: white !important;
}

.sc-item .lunar-day {
	font-size: 10px;
	font-weight: normal;
	overflow: hidden;
	text-overflow: ellipsis;
}

.sc-festival .lunar-day {
	color: #E00808;
}

/*.sc-item:last-child, .sc-item:nth-child(7n) {
  border-width: 0 1px 1px 1px;
}*/
.sc-week-item {
	height: 100%;
	padding-top: 2%;
	float: left;
	width: 14.285%;
	background-color: #FBEC9C;
	border-width: 1px 0 1px 1px;
	border-color: #ECE3B1;
	border-style: solid;
	box-sizing: border-box;
	overflow: hidden;
	text-overflow: ellipsis;
}

.sc-item-small {
	font-size: 10px !important;
}

.sc-week-item:last-child {
	border-width: 1px 1px 1px 1px;
}

.sc-week-item:nth-child(7n), .sc-week-item:nth-child(7n+6) {
	color: rgba(224, 8, 8, 0.74) !important;
}

.sc-actions {
	float: left;
	width: 25%;
	padding: 5px;
	height: 100%;
	box-sizing: border-box;
}

.sc-actions:last-child {
	float: right;
}

.sc-actions-big {
	width: 50%;
}

@media screen and (max-width : 500px) {
	.sc-actions {
		width: 50%;
	}
}

.sc-header select {
	border-color: rgba(0, 0, 0, 0);
	padding: 0.2em;
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	font-family: "Microsoft Yahei";
	color: #606060;
	font-size: 13px;
}

.sc-header input {
	border-color: rgba(0, 0, 0, 0);
	padding: 0.2em;
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	font-family: "Microsoft Yahei";
	color: #606060;
}

.sc-actions div {
	display: inline-block;
	/*border: 1px solid #ccc;*/
	vertical-align: bottom;
	width: 20px;
	padding-bottom: 5px;
	font-size: 1.5em;
	line-height: 0.9em;
}

.sc-return-today {
	display: block;
	background-color: #F5F5F9;
	border-radius: 2px;
	/* border: 1px solid #ccc; */
	width: 60px;
	font-size: 0.8em;
	padding: 0.3em;
	margin: auto;
}

.sc-time {
	display: block;
	margin-top: 3px;
	font-size: 0.8em;
}
</style>

</html>